#!/bin/bash

# 配置
APP_NAME="wbApp:app"  # Flask 应用名，格式为 module:app

# 停止与 APP_NAME 相关的 Gunicorn 进程
echo "Looking for existing Gunicorn process related to $APP_NAME..."

PIDS=$(ps aux | grep "gunicorn" | grep "$APP_NAME" | grep -v "grep" | awk '{print $2}')

if [ -n "$PIDS" ]; then
    for PID in $PIDS; do
        echo "Stopping existing Gunicorn process (PID: $PID)..."
        kill -9 "$PID"
        echo "Process $PID stopped."
    done
else
    echo "No Gunicorn process for $APP_NAME found."
fi
